﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace for7raid.vkConnector
{
    public static class Group
    {
        public const string GroupGetMembers = "groups.getMembers";
        public const string GroupGet = "groups.get";
        public const string GroupGetById = "groups.getById";
        public const string GroupIsMember = "groups.isMember";

        public static Request GetByUserId(int UserId)
        {
            return new Request(GroupGetById).AddParam("uid", UserId).AddParam("extended", 1);

        }

        public static Request GetMembers(int GroupId, int offset)
        {
            return new Request(GroupGetMembers).AddParam("gid", GroupId).AddParam("count", 1000).AddParam("offset", offset);
        }

        public static Request GetMembers(int GroupId)
        {
            return GetMembers(GroupId, 0);
        }

        public static Request GetByIds(params int[] Id)
        {
            return new Request(GroupGetById).AddParam("gids", Id.Select(i => i.ToString()).Aggregate((i, l) => i + "," + l));
        }
        public static Request GetByIds(string Ids)
        {
            return new Request(GroupGetById).AddParam("gids", Ids);
        }
        public static Request GetIsMember(string GroupId, int userId)
        {
            return new Request(GroupIsMember).AddParam("gid", GroupId).AddParam("uid", userId);
        }
    }
}
